/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Banco;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Mailson Kahl
 * email: mkahl.colorado@hotmail.com
 */
public class ConnectionBD {

    private static Connection conn=null; // todas as requisições compartilham a mesma conexão

    public Connection conecta() {

        String strUrl = "jdbc:mysql://localhost:3306/paradigmas"; //driver:sgbd://ip:porta/banco
        String user = "root";
        String pass = "leo230594";
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(strUrl, user, pass); // conecta ao sgbd e ao banco
        } catch (ClassNotFoundException ex) {
            System.out.println(ex.getMessage());
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }
        return conn;
    }

    public void Desconecta() {
        try {
            conn.close();
        } catch (SQLException e) {
            e.getMessage();
        }
    }

    public Connection retornaconn() {
        return conn;
    }
}